<div ng-include src="'views/sidebar.html'"></div>
<section id="page-wrapper" ng-init="search()">
	<form class="form-inline">
		<div class="form-group">
			<div class="btn-group" role="group" aria-label="..." style="margin:10px;">
			 	<img src="images/laptop.png" ng-class="{false: 'btn btn-default', true: 'btn btn-primary'}[pageType==0]" ng-click="changeDeviceType(0)" style="width:50px"title="查看PC">
		        <img src="images/phone.png" ng-class="{false: 'btn btn-default', true: 'btn btn-primary'}[pageType==1]"ng-click="changeDeviceType(1)" style="width:50px"title="查看H5">
		        <!--<img src="images/app.png" ng-class="{false: 'btn btn-default', true: 'btn btn-primary'}[pageType==2]"ng-click="changeDeviceType(2)" style="width:50px"title="查看APP">-->
			</div>
		</div>
		<div class="form-group">
			<div class="checkbox">
				<label><input type="checkbox" ng-model="isOnlyShowMine" ng-change="search()">我关注的</label>
			</div>
			<div class="checkbox">
				<label><input type="checkbox" ng-model="showAbandoned" ng-change="search()">包含废弃专题</label>
			</div>
		</div>
	</form>
	<form class="form-inline">
		<div class="form-group">
			最后编辑时间：
			<select class="form-control" tabindex="2" style="margin:10px;" ng-model="periodOptions" ng-change="search()">
				<option value="LAST_ONE_HOUR" label="最近一小时"></option>
				<option value="LAST_ONE_DAY" label="最近一天"></option>
				<option value="LAST_ONE_WEEK" label="最近一星期" selected></option>
				<option value="LAST_ONE_MONTH" label="最近一个月"></option>
				<option value="ALL" label="全部"></option>
			</select>
		</div>
		<div class="form-group">
			<div class="input-group custom-search-form">
				<input type="text" class="form-control ng-pristine ng-valid ng-touched" placeholder="专题名称或编号" ng-model="searchKeywords" tabindex="0" aria-invalid="false">
				<span class="input-group-btn">
					<button class="btn btn-default" type="submit" ng-click="search()" tabindex="0">
					<i class="fa fa-search"></i>
					</button>
				</span>
			</div>
		</div>
	</form>
	<hr>
	<div class="row">
		<div class="col-md-12">
		<pagination boundary-links="true" max-size="20" items-per-page="25" total-items="totalItems" ng-model="currentPage" class="pagination-sm" previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;" ng-change="search()"></pagination>
	</div>
	<div class="col-md-12">
		<table class="table table-bordered table-hover" style="margin-bottom:100px;">
			<thead>
				<tr>
					<th>关注</th>
					<th>专题编号</th>
					<th>类型</th>
					<th>专题名称</th>
					<th>关联页面</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<tr ng-repeat="topic in topics | filter:isSearch(searchKeywords)">
					<td>
						<a class="btn btn-success" ng-if="topic.watch" ng-click="unwatch(topic.id)"><i class="glyphicon glyphicon-eye-open"></i>已关注</a>
						<a class="btn btn-default" ng-if="topic.watch==false" ng-click="watch(topic.id)"><i class="glyphicon glyphicon-eye-close"></i>未关注</a>
					</td>
					<td>{{topic.id}}</td>
					<td><img src='images/laptop.png' ng-if="topic.type==0" style="width:30px">
						<img src='images/phone.png' ng-if="topic.type==1" style="width:30px">
						<img src='images/app.png' ng-if="topic.type==2" style="width:30px">
					</td>
					<td ng-if="topic.isDelete" style="background:#ddd"><del>{{topic.title}}</del></td>
					<td ng-if="!topic.isDelete">{{topic.title}}</td>
					<td>{{topic.pageId}}</td>
					<td>
						<div class="btn-group">
							<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
							操作 <span class="caret"></span>
							</button>
							<ul class="dropdown-menu">
								<li><a href="javascript:" ng-click="open(topic, $index)"><i class="fa fa-edit"></i>修改属性</a></li>
								<li ng-if="profile.role=='ADMIN'"><a href="javascript:" ng-click="delete(topic.id)" class="btn-danger"><i class="fa fa-remove"></i>删除专题</a></li>
								<li ng-if="profile.role=='ADMIN'"><a href="javascript:" ng-click="rollback(topic.id)"><i class="fa fa-recycle"></i>恢复专题</a></li>
							</ul>
						</div>
						<div class="btn-group">
							<a href="#/page/edit/{{topic.pageId}}" class="btn btn-default"><i class="fa fa-sign-in"></i>装修</a>
						</div>
						<div class="btn-group">
							<a ng-if="topic.type==0" ng-href="http://www.tepin.hk/activity/{{topic.id}}.html" target="_blank" title="预览" class="btn btn-primary"><i class="fa fa-link"></i>浏览线上</a>
							<a ng-if="topic.type!=0" ng-href="http://m.tepin.hk/activity/{{topic.id}}.html" target="_blank" title="预览" class="btn btn-primary"><i class="fa fa-link"></i>浏览线上</a>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
	<div class="col-md-12">
	<pagination boundary-links="true" max-size="20" items-per-page="25" total-items="totalItems" ng-model="currentPage" class="pagination-sm" previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;" ng-change="search()"></pagination>
</section>
<script type="text/ng-template" id="topic.property.edit.html">
<input type="file" style="display:none;" id="fileuploader"/>
<form class="form-horizontal">
	<div class="modal-header">
		<h3 class="modal-title">修改专题</h3>
	</div>
	<div class="modal-body">
		<div class="form-group">
			<label class="col-sm-2 control-label">专题id</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" ng-model="topic.id" disabled>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">专题状态</label>
			<div class="col-sm-10">
				<select class="form-control" ng-model="topic.status">
                     <option value="DRAFT">下线</option>
                     <option value="PUBLISH">上线</option>
                  </select>
			</div>
		</div>
		<div class="form-group">
            <label class="col-sm-2 control-label">专题banner</label>
            <div class="col-sm-10">
              <div class="input-group">
                <input type="text" class="form-control" ng-model="topic.fileName">
                <span class="input-group-btn">
                  <button class="btn btn-default" ng-click="changeFile(topic)" tabindex="0">
                  <i class="glyphicon glyphicon-folder-open"></i>
                  </button>
                  <button class="btn btn-success" tabindex="0" ng-if="topic.isCompleted">
                  <i class="glyphicon glyphicon-ok"></i>
                  </button>
                </span>
              </div>
            </div>
          </div>
		<div class="form-group">
			<label class="col-sm-2 control-label">开始时间</label>
			<div class="col-sm-10">
				<div class=' input-group date' ng-init="initTime()">
                    <input type='text' class="form-control datetimepicker datetimepicker1" ng-model="topic.starttime" ng-blur="dateChange(topic,1)" />
                    <span class="input-group-addon">
            		<span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">结束时间</label>
			<div class="col-sm-10">
				<div class=' input-group date' ng-init="initTime()">
                    <input type='text' class="form-control datetimepicker datetimepicker2" ng-model="topic.endtime" ng-blur="dateChange(topic,2)" />
                    <span class="input-group-addon">
            		<span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
			</div>
		</div>
	
		<div class="form-group">
			<label class="col-sm-2 control-label">专题名称</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" ng-model="topic.title" autofocus onfocus="this.select()">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">页面编号</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" ng-model="topic.pageId">
			</div>
		</div>
	</div>
	<div class="modal-footer">
		<button class="btn btn-success" ng-click="save(topic)" type="submit">保存</button>
		<button class="btn btn-default" ng-click="cancel()">取消</button>
	</div>
</form>
</script>